using System;
using System.Collections;
using PHSRAG.Insight21.Common.Pages;
using PHSRAG.Insight21.Policy;
using PHSRAG.Utility;
using Workflow.NET.Web.Designer;

namespace PHSRAG.Insight21.Humans
{
    /// <summary>
    /// This web page will dyanamically load the workflow selected(requested) by the user.Work flow selection is available from the WorkFlowmangaer.aspx page
    /// </summary>
    public partial class DetailedWorkFlowForm : BasePage
    {
        #region protected variables

        protected ProcessDesigner _processDesigner;

        #endregion

        #region private variables

        private ICachePolicy _cachePolicy;

        #endregion

        /// <summary>
        /// Page load eventhandler
        /// </summary>
        /// <param name="sender">The control("Page" in this case) which initiated the action</param>
        /// <param name="e">The event arguments related to the page</param>
        protected void OnPageLoad(object sender, EventArgs e)
        {
            _processDesigner = new ProcessDesigner();
            _processDesigner.ApplicationName = Settings.GetKeyValue("InsightApplicationName", string.Empty);
            _processDesigner.Height = 800;
            Hashtable incomingPageHash = _cachePolicy.GetCachedObject(Keys.IncomingDataKey) as Hashtable;
            if (incomingPageHash != null)
            {
                _processDesigner.WorkflowName = Convert.ToString(incomingPageHash[Keys.SelectedWFlowKey]);
                showWorkFlow.Controls.Add(_processDesigner);
            }
        }

        #region Web Form Designer generated code

        protected override void OnInit(EventArgs e)
        {
            //
            // CODEGEN: This call is required by the ASP.NET Web Form Designer.
            //
            InitializeComponent();
            base.OnInit(e);
            _cachePolicy = (Policy.ICachePolicy) Session[Policy.Names.CachePolicyKey];
        }

        /// <summary>
        /// Required method for Designer support - do not modify
        /// the contents of this method with the code editor.
        /// </summary>
        private void InitializeComponent()
        {
            this.ID = "DetailedWorkFlowForm";
            this.Load += new System.EventHandler(this.OnPageLoad);
        }

        #endregion
    }
}